import { defineStore } from "pinia";
import { JxtechSysConfig } from "@/stores/interface/sysconfig";

export const useSysconfigrStore = defineStore({
  id: "jxtech-sysconfig",
  state: (): JxtechSysConfig => {
    return {
      /**新增用户*/
      addPerson: false,
      /**应用id*/
      appId: "",
      /**应用名称*/
      appName: "",
      /**请求头名称*/
      authHeaderName: "",
      /**应用id*/
      clientid: "",
      cmsExist: false,
      /**公司名称*/
      corp: "",
      /**当前得应用id*/
      currentComp: "",
      /**数据库模式*/
      databaseSchema: "",
      /**是否加密密码*/
      encodePassword: false,
      /**加密类型 */
      encriptType: "",
      fouraHost: "",
      /**网关地址*/
      gatewayUrl: "",
      haveSubOrg: false,
      /**是否开启国际化*/
      i18n: false,
      initMenuButtonVisible: false,
      /**语言*/
      locale: "",
      /**登录背景 */
      loginBgc: "",
      loginBluesysLogo: "",
      loginBox: "",
      loginDarkLogo: "",
      loginLightLogo: "",
      /**刷新token地址*/
      loginRefreshToken: "",
      /**登录类型*/
      loginType: "",
      messageExist: false,
      /**登录地址*/
      oauth2Url: "",
      preventRepeat: false,
      pwdValidDays: 0,
      pwdValidEnabled: false,
      pwdValidHintDays: 0,
      /**mq 密码*/
      rabbitPassword: "",
      /**队列类型*/
      rabbitQueuetype: "",
      /**mq 用户名*/
      rabbitUsername: "",
      /**是否开启验证码*/
      randomCode: false,
      rememberMe: false,
      /**rsa加密公钥 */
      rsaPublicKey: "",
      /**会话超时 */
      sessiontimeout: 0,
      showTrace: false,
      /**租户管理部门*/
      tenantManagerUnit: "",
      thirdSSOHeaderName: "",
      /**用户账号类型*/
      userAccountType: "",
      userHaveOnlyOneUnit: false,
      /**用户等级 */
      userLevel: false,
      /**ws路径*/
      websocketPath: "",
      workflowExist: false,
      /**aes key*/
      aeskey: "",
      /**aes iv*/
      aesiv: ""
    };
  },
  actions: {
    setSysConfig(sysconfig: JxtechSysConfig) {
      this.addPerson = sysconfig.addPerson;
      this.appId = sysconfig.appId;
      this.appName = sysconfig.appName;
      this.authHeaderName = sysconfig.authHeaderName;
      this.clientid = sysconfig.clientid;
      this.cmsExist = sysconfig.cmsExist;
      this.corp = sysconfig.corp;
      this.currentComp = sysconfig.currentComp;
      this.databaseSchema = sysconfig.databaseSchema;
      this.encodePassword = sysconfig.encodePassword;
      this.encriptType = sysconfig.encriptType;
      this.fouraHost = sysconfig.fouraHost;
      this.gatewayUrl = sysconfig.gatewayUrl;
      this.haveSubOrg = sysconfig.haveSubOrg;
      this.i18n = sysconfig.i18n;
      this.initMenuButtonVisible = sysconfig.initMenuButtonVisible;
      this.locale = sysconfig.locale;
      this.loginBgc = sysconfig.loginBgc;
      this.loginBluesysLogo = sysconfig.loginBluesysLogo;
      this.loginBox = sysconfig.loginBox;
      this.loginDarkLogo = sysconfig.loginDarkLogo;
      this.loginLightLogo = sysconfig.loginLightLogo;
      this.loginRefreshToken = sysconfig.loginRefreshToken;
      this.loginType = sysconfig.loginType;
      this.messageExist = sysconfig.messageExist;
      this.oauth2Url = sysconfig.oauth2Url;
      this.preventRepeat = sysconfig.preventRepeat;
      this.pwdValidDays = sysconfig.pwdValidDays;
      this.pwdValidEnabled = sysconfig.pwdValidEnabled;
      this.pwdValidHintDays = sysconfig.pwdValidHintDays;
      this.rabbitPassword = sysconfig.rabbitPassword;
      this.rabbitQueuetype = sysconfig.rabbitQueuetype;
      this.rabbitUsername = sysconfig.rabbitUsername;
      this.randomCode = sysconfig.randomCode;
      this.rememberMe = sysconfig.rememberMe;
      this.rsaPublicKey = sysconfig.rsaPublicKey;
      this.sessiontimeout = sysconfig.sessiontimeout;
      this.showTrace = sysconfig.showTrace;
      this.tenantManagerUnit = sysconfig.tenantManagerUnit;
      this.thirdSSOHeaderName = sysconfig.thirdSSOHeaderName;
      this.userAccountType = sysconfig.userAccountType;
      this.userHaveOnlyOneUnit = sysconfig.userHaveOnlyOneUnit;
      this.userLevel = sysconfig.userLevel;
      this.websocketPath = sysconfig.websocketPath;
      this.workflowExist = sysconfig.workflowExist;
      this.aeskey = sysconfig.aeskey;
      this.aesiv = sysconfig.aesiv;
    },
    clearSysConfig() {
      this.$reset();
    }
  }
});
